package com.ihrm.common.entity;


import lombok.Data;

/**
 * 封装响应对象
 * @author chahua
 * @date 2022/3/26 13:17
 **/
@Data
public class Result {
    private boolean success;
    private int code;
    private String message;
    private Object data;

    public Result(ResultCode resultCode){
        this.success = resultCode.success;
        this.code = resultCode.getCode();
        this.message = resultCode.getMessage();
    }

    public Result(ResultCode resultCode,Object data){
        this.success = resultCode.success;
        this.code = resultCode.getCode();
        this.message = resultCode.getMessage();
        this.data = data;
    }

    public Result(boolean success,int code,String message){
        this.success = success;
        this.code = code;
        this.message = message;
    }

    public static Result SUCCESS(){
        return new Result(ResultCode.SUCCESS);
    }

    public static Result FAIL(){
        return new Result(ResultCode.FAIL);
    }

    public static Result ERROR(){
        return new Result(ResultCode.SERVER_ERROR);
    }
}
